<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/metro-gray/easyui.css"/>
<link rel="stylesheet" href="static/easyui/themes/icon.css"/>
<title>处方开药</title>
</head>
<body>
<script type="text/javascript">

//时间转换
function comformatDate(date) {
	var day = new Date(date); 
	var Year = 0; 
	var Month = 0; 
	var Day = 0; 
	var CurrentDate = ""; 
	//初始化时间 
	Year= day.getFullYear();//
	Month= day.getMonth()+1; 
	Day = day.getDate(); 
	Hour = day.getHours(); 
	 Minute = day.getMinutes(); 
	 Second = day.getSeconds(); 
	CurrentDate += Year + "-"; 
	if (Month >= 10 ) { 
		CurrentDate += Month + "-"; 
	}else { 
		CurrentDate += "0" + Month + "-"; 
	} 
	if (Day >= 10 ) { 
		CurrentDate += Day ; 
	}else { 
		CurrentDate += "0" + Day ; 
	} 
	if(Hour>=10){
		CurrentDate +=" "+Hour;
	}else{
		CurrentDate +=" "+"0"+Hour;
	}
	if(Minute>=10){
		CurrentDate +=":"+Minute;
	}else{
		CurrentDate +=":"+"0"+Minute;
	}
	if(Second>=10){
		CurrentDate +=":"+Second;
	}else{
		CurrentDate +=":"+"0"+Second;
	}
	return CurrentDate; 
};
$(function(){
	//访问数据源、初始化表格
	$('#sqjl').datagrid({
		url:'sqjls',
		onLoadSuccess: function (data) {
            if (data.total == 0) {
                //添加一个新数据行，第一列的值为你需要的提示信息，然后将其他列合并到第一列来，注意修改colspan参数为你columns配置的总列数
                $(this).datagrid('appendRow', { sqid: '<div style="text-align:center;color:red">没有相关记录！</div>' }).datagrid('mergeCells', { index: 0, field: 'sqid', colspan: 6 })
                //隐藏分页导航条，这个需要熟悉datagrid的html结构，直接用jquery操作DOM对象，easyui datagrid没有提供相关方法隐藏导航条
                $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
            }
            //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
            else $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
        },
		columns:[[
					{field:'sqid',title:'申请id',width:100},
					{field:'sqtime',title:'申请时间',width:100,formatter:comformatDate},
					{field:'sqty',title:'是否同意',width:100,align:'right'},
					{field:'zt',title:'状态',width:100,align:'right'},
					{field:'jbr',title:'状态',width:100,align:'right'},
					{field:'cz',title:'操作*',width:200,
						formatter:function(value,row,index){
							return "<input type='button' style='background:#E4F1FB;color:#2779AA;border:none' onclick='shenqingxq("+row.sqid+")' value='详情'/>";
						}	
					}
				]]
				
		});
	
	//名字查询
	$('#shijiancx').searchbox({
		searcher:function(value){
		    alert(value);
		    	   $('#sqjl').datagrid({
	    				url:'sqsjcx',
	    				queryParams:{
	    					nameq:value
	    				},
	    				onLoadSuccess: function (data) {
	    		            if (data.total == 0) {
	    		                //添加一个新数据行，第一列的值为你需要的提示信息，然后将其他列合并到第一列来，注意修改colspan参数为你columns配置的总列数
	    		                $(this).datagrid('appendRow', { sqid: '<div style="text-align:center;color:red">没有相关记录！</div>' }).datagrid('mergeCells', { index: 0, field: 'sqid', colspan: 6 })
	    		                //隐藏分页导航条，这个需要熟悉datagrid的html结构，直接用jquery操作DOM对象，easyui datagrid没有提供相关方法隐藏导航条
	    		                $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
	    		            }
	    		            //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
	    		            else $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
	    		        },
	    				columns:[[
	    					{field:'sqid',title:'申请id',width:100,align:'center'},
	    					{field:'sqtime',title:'申请时间',width:100,formatter:comformatDate,align:'center'},
	    					{field:'sqty',title:'是否同意',width:100,align:'center'},
	    					{field:'zt',title:'状态',width:100,align:'center'},
	    					{field:'jbr',title:'状态',width:100,align:'center'},
	    					{field:'cz',title:'操作*',width:200,align:'center',
	    						formatter:function(value,row,index){
	    							return "<input type='button' style='background:#E4F1FB;color:#2779AA;border:none' onclick='shenqingxq("+row.sqid+")' value='详情'/>";
	    						}	
	    					}
	    						]]
						});
		    }
		    
		  
	});
	
})
	function shenqingxq(a){
		$("#sqxq").window("open");
		//访问数据源、初始化表格
		$('#sqypxq').datagrid({
			url:'sqypsy',
			queryParams:{
				sqid:a
			},
			columns:[[
						{field:'ypname',title:'药品名称',width:100,align:'center'},
						{field:'yptype',title:'药品类别',width:100,align:'center'},
						{field:'ypsl',title:'申请数量',width:100,align:'center'}
					]]
					
			});
	}
</script> 
<div class="easyui-panel" data-options="fit:true">
<p>
	时间查询：<input id="shijiancx" class="easyui-searchbox">
	</p>
			<table id="sqjl" class="easyui-datagrid" data-options="fitColumns:true,pagination:true"  style="height:400px">
				
		</table>
	</div>
	<div id="sqxq" title="申请详情" class="easyui-window" data-options="closed:true">
			<table id="sqypxq" class="easyui-datagrid" data-options="fitColumns:true,pagination:true"  style="height:400px;width:500px">

		</table>
	</div>
</body>
</html>